import bisect
from bisect import bisect_left
from collections import defaultdict
from typing import List, Optional


class Solution:
    def minWindow(self, s: str, t: str) -> str:
        if len(t) == 1:
            return t if t in s else ''
        map1 = defaultdict(list)
        left = -1
        right = -1
        for i in range(len(s)):
            map1[s[i]].append(i)
        for j in map1[t[0]]:
            l = j
            r = j
            for k in range(1,len(t)):
                lis = map1[t[k]]
                pos = bisect.bisect_right(lis,r)
                if pos == len(lis):
                    break
                else:
                    r = lis[pos]
            if left==-1 or r-l<right-left:
                left = l
                right = r
        return s[left:right+1]

s1 = "ADOBECODEBANC"
s2 = "ABC"
arr = [1,3,5,4,7]

# obstacleGrid = ["leet","code"]
Solution().minWindow(s1,s2)




